unit PluginIde;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, AdvMemo, StdCtrls, RzLstBox, RzTabs, ExtCtrls, RzPanel, RzSplit,
  Menus, AdvCodeList, AdvmPS;

type
  TForm2 = class(TForm)
    MainMenu1: TMainMenu;
    Bestand1: TMenuItem;
    Openen1: TMenuItem;
    Opslaanals1: TMenuItem;
    Compileren1: TMenuItem;
    Run1: TMenuItem;
    Afsluiten1: TMenuItem;
    OpenDialog1: TOpenDialog;
    RzSplitter1: TRzSplitter;
    RzSplitter2: TRzSplitter;
    AdvMemo1: TAdvMemo;
    debug: TMemo;
    RzPageControl1: TRzPageControl;
    TabSheet1: TRzTabSheet;
    TabSheet2: TRzTabSheet;
    RzListBox1: TRzListBox;
    AdvPascalMemoStyler1: TAdvPascalMemoStyler;
    SaveDialog1: TSaveDialog;
    Debuglog1: TMenuItem;
    Clear1: TMenuItem;
    procedure Openen1Click(Sender: TObject);
    procedure Run1Click(Sender: TObject);
    procedure Opslaanals1Click(Sender: TObject);
    procedure Clear1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

uses
   Unit1;

procedure TForm2.Clear1Click(Sender: TObject);
begin
   debug.Lines.Clear;
end;

procedure TForm2.Openen1Click(Sender: TObject);
begin
    if OpenDialog1.Execute then
    begin
      AdvMemo1.Lines.Clear;
      AdvMemo1.Lines.LoadFromFile(OpenDialog1.FileName);
    end;
end;

procedure TForm2.Opslaanals1Click(Sender: TObject);
begin
    if SaveDialog1.Execute then
    Begin
      AdvMemo1.Lines.SaveToFile(SaveDialog1.FileName);
    End;
end;

procedure TForm2.Run1Click(Sender: TObject);
begin

   try
    unit1.Form1.scripter.Source.Text := AdvMemo1.Lines.Text;
    unit1.Form1.scripter.Active := True;

     try
       unit1.Form1.scripter.RunProc('Main');
      except
        on e: Exception do
         debug.Lines.Add('Fout: '+ e.Message);
     end;
    finally
       unit1.Form1.scripter.Active := false;
    end;

end;

end.
